package com.tsmti.lab.controller.system;

import com.tsmti.core.common.controller.BaseController;
import com.tsmti.core.common.model.AjaxJson;
import com.tsmti.core.util.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Package：com.tsmti.lab.controller.system
 * @Class：CommonController
 * @Description： TODO
 * @Author：zcw
 * @Date：Created in 2018/4/19 16:18
 * @Company:
 * @Version：
 * @Modified By:
 */
@Controller
@RequestMapping("/system/common")
public class CommonController extends BaseController {

    /**
     * 图表资源
     *
     * @return
     */
    @RequestMapping(value = "icons", method = RequestMethod.GET)
    public String list(Model model) {
        return display("icons");
    }

    @RequestMapping(value = "treeselect", method = RequestMethod.GET)
    public String treeselect(Model model, HttpServletRequest request) {
        // 树结构数据URL
        model.addAttribute("url", request.getParameter("url"));
        String multiselect = request.getParameter("multiselect");
        String chkboxType = request.getParameter("chkboxType");
        // 父子关联
        model.addAttribute("chkboxType", chkboxType);
        if (StringUtils.isEmpty(multiselect)) {
            multiselect = Boolean.TRUE + "";
        }
        // 是否多选
        model.addAttribute("multiselect", multiselect);
        String selectNodes = request.getParameter("selectNodes");
        // 默认值
        model.addAttribute("selectNodes", selectNodes);
        return display("treeselect");
    }

    /***
     * 列定制
     * @param model
     * @return
     */
    @RequestMapping(value = "showcol", method = RequestMethod.GET)
    public String showcol(Model model, HttpServletRequest request) {
        model.addAttribute("pageId",request.getParameter("pageId"));
        model.addAttribute("gridId",request.getParameter("gridId"));
        return display("showcol");
    }

}
